package com.sleep.satokendemo.entry;

import com.sleep.satokendemo.util.StatusCode;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @ClassName R
 * @Description TODO
 * @Author 郭敖
 * @Date 2024年03月31日 19:07
 * @Version 1.0
 */
@Data
@Accessors(chain = true)
public class R {
    private Integer code;
    private String msg;
    private Object result;

    public static R error(String message) {
        return new R().setCode(StatusCode.FAIL)
                .setMsg(message);
    }

    public static R success(String message) {
        return new R().setCode(StatusCode.SUCCESS)
                .setMsg(message);
    }

    public static R success(String message, Object result) {
        return new R().setCode(StatusCode.SUCCESS)
                .setMsg(message)
                .setResult(result);
    }
}
